﻿using B.S.Traceability.Domain;
using B.S.Traceability.Error;
using B.S.Traceability.Infrastructure.Interface;
using B.S.Traceability.Read.API.Application.Commends;
using MediatR;

namespace B.S.Traceability.Read.API.Application.CommendHandlers
{
    public class QueryShoopCommendHandlers : IRequestHandler<QueryShoopCommends, APIResult<List<Shoops>>>
    {

        private readonly IBaseRepository<Shoops> shoopsRepository;

        public QueryShoopCommendHandlers(IBaseRepository<Shoops> shoopsRepository)
        {
            this.shoopsRepository = shoopsRepository;
        }

        /// <summary>
        /// 显示商品名称
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<APIResult<List<Shoops>>> Handle(QueryShoopCommends request, CancellationToken cancellationToken)
        {
            APIResult<List<Shoops>> result = new APIResult<List<Shoops>>();

            result.Code = APIEnum.查询成功;
            result.Msg=APIEnum.查询成功.ToString();
            var list=shoopsRepository.GetAllAsync().Result;

            result.data = list.ToList();

            return Task.FromResult(result);
        }
    }
}
